package top.yaofengqiao.springcloudsimple.auth.biz.domain.security.model;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import top.yaofengqiao.springcloudsimple.auth.biz.domain.auth.model.valobj.Oauth2Type;

import java.util.Collections;

/**
 * @author yfq
 * @date 2024/6/11 14:01
 * @description
 */
public class Oauth2AuthenticationToken extends AbstractAuthenticationToken {
    private final String openid;
    @Getter
    private final Oauth2Type oauth2Type;
    @Setter
    private UserInfo userInfo;

    public Oauth2AuthenticationToken(String openid, Oauth2Type oauth2Type) {
        super(Collections.emptyList());
        this.openid = openid;
        this.oauth2Type = oauth2Type;
    }

    @Override
    public Object getCredentials() {
        return openid;
    }

    @Override
    public Object getPrincipal() {
        return userInfo;
    }
}
